const sqlhelper = require('../sqlhelper/sqlhelper');

module.exports = {
  getAllCategories(callback) {
    let connection = sqlhelper.getConnection();
    let sql = "select * from categories";
    connection.query(sql, (err, result) => {
      callback(err, result);
    });
  },
  addNewHero(data,callback){
    let connection = sqlhelper.getConnection();
    let sql = 'insert into categories set ?'
    connection.query(sql,data,(err,result)=>{
      callback(err,result);
    })
  },
  deleteCategoryMutilple(ids,callback){
    let connection = sqlhelper.getConnection();
    let sql = `delete from categories where id in ( ${ids.join(',')} )`;
    connection.query(sql,(err,result)=>{
      err ? callback(err) : callback(err,result);
    })
  }
}